//
//  BaseViewController.swift
//  IDF
//
//  Created by 陈徐挺 on 26/03/2018.
//  Copyright © 2018 Jesse.chen. All rights reserved.
//

import UIKit
import EasyPeasy

class BaseViewController: UIViewController {
    var navTitle: String = ""

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor(hexString: "#F5F5F5")
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        if navTitle != "" {
            navigationItem.title = navTitle
        }
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        if let title = navigationItem.title {
            navTitle = title
        }
        navigationItem.title = ""
    }

    deinit {

        dPrint(self.className() + "     deinit")

    }
    
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let view  = UIView()
        if(tableView.dataSource!.responds(to: #selector(UITableViewDataSource.tableView(_:titleForHeaderInSection:)))) {
            let sectionTitle = tableView.dataSource?.tableView!(tableView, titleForHeaderInSection: section)
            let label = UILabel()
            label.text = sectionTitle
            label.font = UIFont.systemFont(ofSize: 14)
            label.textColor = UIColor(hexString: "#666666")
            view.addSubview(label)
            view.backgroundColor = UIColor(hexString: "#F5F5F5")
            label <- [
                Left(15).to(view, .left),
                CenterY()
            ]
        }
        return view
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
extension BaseViewController {
    

    
}
